function axios(urlOrConfig,config={}){
	if(typeof urlOrConfig === "string"){
		config.url = urlOrConfig;
	}else{
		config = urlOrConfig;
	}
	let {url,type:method='get',params,headers={},data:body} = config;
	console.log(url);
	return new Promise(function(resolve){
		if(params){
			url+="?"+Object.keys(params).map(key=>key+"="+params[key]).join("&");
		}
		if(["post","delete","put"].includes(method.toLowerCase()) && body){
			if(body instanceof Object){
				headers["Content-Type"] = "application/json";
				body = JSON.stringify(body);
			}else{
				headers["Content-Type"] = "application/x-www-form-urlencoded"
			}
		}
		fetch(url,{
			method,
			body,
			headers
		}).then(value=>value.json()).then(data=>{
			resolve({
				data
			})
		})
	})
}
axios.get = function(url,config){
	return axios({
		...config,
		url
	})
}
axios.post = function(url,config){
	return axios({
		...config,
		url,
		type:"post"
	})
}
export default axios;